# -*- coding: UTF-8 -*-
import pytest
import sqlite3
import time

@pytest.fixture(scope='module')
def connects():
    conn = sqlite3.connect('funds.db')
    print('连接成功')
    yield conn
    conn.close()
    print('连接关闭')

@pytest.fixture(scope='module',autouse=True)
def r_time():
    startTime = time.time()
    yield
    endTime = time.time()
    useTime = endTime-startTime
    print('耗时：',useTime)

def test1_conn(connects):
    cur = connects.cursor()
    data = cur.execute('select count(*) from fund')
    value = data.fetchone()
    result = value[0]
    assert result == 11201

def test2_conn(connects):
    cur = connects.cursor()
    data = cur.execute('select * from fund')
    results = data.fetchall()
    result = len(results)
    assert result == 11201


if __name__ == '__main__':
    pytest.main(['-s','yangsy.py'])


